// pages/camel_card/my_camelCard/index.js
var app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    imgurl: app.urlimg,
    member_status: 0,  // 0为未激活状态  1为已激活的状态
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this;

    app.app_load(load_fn);

    function load_fn() {
      wx.showLoading({
        title: '加载中...',
      });
      wx.request({
        url: app.url + 'api_ucenter/camelCard',
        data: {
        },
        header: {
          'content-type': 'application/json',
          'token': wx.getStorageSync('token_key')
        }, success: function (json) {
          wx.hideLoading();
          if (json.data.done == true) {
            var res = json.data.result;
            res.user_status.user_grade = parseInt(res.user_status.user_grade) + 1;
            that.setData({
              member_status: parseInt(res.member_status),
              user_status: (res.user_status ? res.user_status : ''),
              camel_card: (res.camel_card ? res.camel_card : ''),
              interest: (res.interest ? res.interest : ''),
            })
          }
        }
      })
    }

  },
  // 激活会员卡
  activation_click: function (e) {
    wx.navigateTo({
      url: '/pages/camel_card/activation/index',
    })
  },
  // 余额明细
  details: function () {
    wx.navigateTo({
      url: "/pages/camel_card/my_camelCard_details/index?user_id=" + this.data.user_status.user_id,
    })
  },
  // 充值
  recharge: function () {
    wx.navigateTo({
      url: "/pages/camel_card/my_camelCard_recharge/index?user_id=" + this.data.user_status.user_id,
    })
  },
  //找回密码
  find_password: function (e) {
    var type = this.data.user_status.pwdStatus ? 'forget' : 'set'//找回或设置
    wx.navigateTo({
      url: "/pages/camel_card/my_camelCard_find_password/index?type=" + type,
    })
  },
})